################################################################################
#
# recalbox-romfs-saturn
#
################################################################################

# Package generated with :
# ./scripts/linux/empack.py --force --system saturn --extension '.cue .CUE .toc .TOC .m3u .M3U .ccd .CCD .chd .CHD .iso .ISO .mds .MDS .zip .ZIP .7z .7Z' --fullname 'Sega Saturn' --platform saturn --theme saturn 1:libretro:mednafen_saturn:BR2_PACKAGE_LIBRETRO_BEETLE_SATURN 4:libretro:kronos:BR2_PACKAGE_LIBRETRO_KRONOS 3:libretro:yabasanshiro:BR2_PACKAGE_LIBRETRO_YABASANSHIRO 2:libretro:yabause:BR2_PACKAGE_LIBRETRO_YABAUSE

# Name the 3 vars as the package requires
RECALBOX_ROMFS_SATURN_SOURCE = 
RECALBOX_ROMFS_SATURN_SITE = 
RECALBOX_ROMFS_SATURN_INSTALL_STAGING = NO
# Set the system name
SYSTEM_NAME_SATURN = saturn
SYSTEM_XML_SATURN = $(@D)/$(SYSTEM_NAME_SATURN).xml
# System rom path
SOURCE_ROMDIR_SATURN = $(RECALBOX_ROMFS_SATURN_PKGDIR)/roms

# CONFIGGEN_STD_CMD is defined in recalbox-romfs, so take good care that
# variables are global across buildroot


ifneq ($(BR2_PACKAGE_LIBRETRO_BEETLE_SATURN)$(BR2_PACKAGE_LIBRETRO_KRONOS)$(BR2_PACKAGE_LIBRETRO_YABASANSHIRO)$(BR2_PACKAGE_LIBRETRO_YABAUSE),)
define CONFIGURE_MAIN_SATURN_START
	$(call RECALBOX_ROMFS_CALL_ADD_SYSTEM,$(SYSTEM_XML_SATURN),Sega Saturn,$(SYSTEM_NAME_SATURN),.cue .CUE .toc .TOC .m3u .M3U .ccd .CCD .chd .CHD .iso .ISO .mds .MDS .zip .ZIP .7z .7Z,saturn,saturn)
endef

ifneq ($(BR2_PACKAGE_LIBRETRO_BEETLE_SATURN)$(BR2_PACKAGE_LIBRETRO_KRONOS)$(BR2_PACKAGE_LIBRETRO_YABASANSHIRO)$(BR2_PACKAGE_LIBRETRO_YABAUSE),)
define CONFIGURE_SATURN_LIBRETRO_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_SATURN),libretro)
endef
ifeq ($(BR2_PACKAGE_LIBRETRO_YABASANSHIRO),y)
define CONFIGURE_SATURN_LIBRETRO_YABASANSHIRO_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SATURN),yabasanshiro,3)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_KRONOS),y)
define CONFIGURE_SATURN_LIBRETRO_KRONOS_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SATURN),kronos,4)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_BEETLE_SATURN),y)
define CONFIGURE_SATURN_LIBRETRO_MEDNAFEN_SATURN_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SATURN),mednafen_saturn,1)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_YABAUSE),y)
define CONFIGURE_SATURN_LIBRETRO_YABAUSE_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_SATURN),yabause,2)
endef
endif

define CONFIGURE_SATURN_LIBRETRO_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_SATURN))
endef
endif



define CONFIGURE_MAIN_SATURN_END
	$(call RECALBOX_ROMFS_CALL_END_SYSTEM,$(SYSTEM_XML_SATURN),$(SOURCE_ROMDIR_SATURN),$(@D))
endef
endif

define RECALBOX_ROMFS_SATURN_CONFIGURE_CMDS
	$(CONFIGURE_MAIN_SATURN_START)
	$(CONFIGURE_SATURN_LIBRETRO_START)
	$(CONFIGURE_SATURN_LIBRETRO_YABASANSHIRO_DEF)
	$(CONFIGURE_SATURN_LIBRETRO_KRONOS_DEF)
	$(CONFIGURE_SATURN_LIBRETRO_MEDNAFEN_SATURN_DEF)
	$(CONFIGURE_SATURN_LIBRETRO_YABAUSE_DEF)
	$(CONFIGURE_SATURN_LIBRETRO_END)
	$(CONFIGURE_MAIN_SATURN_END)
endef

$(eval $(generic-package))
